package edu.gu.hajo.gcl.script;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Simple utility
 * 
 * @author hajo
 * 
 */
public class ScriptFileReader {

	private StringBuffer script = new StringBuffer();

	public ScriptFileReader(String filename) {
		Scanner in = null;
		try {
			in = new Scanner(new File(filename));
			while (in.hasNext()) {
				String line = in.nextLine();
				//Remove empty lines, comments and lines with only space
				if (line.length() > 0 && line.charAt(0) != '#'
						&& !line.matches("[ \t\r]*")) {
					script.append(line + '\n');
				}
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public String getContent() {
		return script.toString();
	}
}
